<%--

  @author yulezhisi
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>客户开发计划</title>

    <link rel="shortcut icon" href="<c:url value="/images/favicon.ico"/>" type="image/x-icon"/>
    <script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
    <script src="<c:url value="/layui/layui.js"/>"></script>
    <link rel="stylesheet" type="text/css" href="<c:url value="/layui/css/layui.css"/>">

    <script src="<c:url value="/js/my/commons.js"/>"></script>
    <style>
        .container {
            width: 1200px;
            margin: 100px auto;
        }
    </style>
</head>
<body>

<div style="margin-left: 140px;margin-right: 100px">
    <div class="layui-fluid">
        <div class="layui-card">

            <div class="layui-form layuiadmin-card-header-auto" lay-filter="layadmin-userfront-formlist"
                 style="margin-left: 270px;margin-bottom: 50px;margin-top: 100px">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label">客户名称</label>
                        <div class="layui-input-block">
                            <input id="name" name="name"
                                   type="text" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">概要</label>
                        <div class="layui-input-block">
                            <input id="general" name="general"
                                   type="text" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">联系人</label>
                        <div class="layui-input-block">
                            <input id="customerName" name="customerName"
                                   type="text" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button id="search" class="layui-btn layuiadmin-btn-useradmin lay-submit"
                                lay-filter="LAY-user-front-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>

                </div>
            </div>

            <table id="test" lay-filter="test" class="layui-hide" height=100></table>

            <div>

                <script type="text/html" id="table-useradmin-webuser">

                    <%--                    <a id="zdjh" lay-event="zdjh" class="layui-btn layui-btn-normal layui-btn-xs">--%>
                    <%--                        <i class="layui-icon layui-icon-edit"></i>制定计划--%>
                    <%--                    </a>--%>

                    <%--                    <a id="zxjh" lay-event="zxjh" class="layui-btn layui-btn-danger layui-btn-xs">--%>
                    <%--                        <i class="layui-icon layui-icon-delete"></i>执行计划--%>
                    <%--                    </a>--%>

                    <%--                    <a id="kfcg" lay-event="kfcg" class="layui-btn layui-btn-danger layui-btn-xs">--%>
                    <%--                        <i class="layui-icon layui-icon-delete"></i>开发成功--%>
                    <%--                    </a>--%>

                    <%--                    <a id="ck" lay-event="ck" class="layui-btn layui-btn-danger layui-btn-xs">--%>
                    <%--                        <i class="layui-icon layui-icon-delete"></i>查看--%>
                    <%--                    </a>--%>
                    {{#  if(d.status =='开发中'){ }}
                    <a id="zdjh" lay-event="zdjh" class="layui-btn layui-btn-normal layui-btn-xs">
                        <i class="layui-icon layui-icon-edit"></i>制定计划
                    </a>

                    <a id="zxjh" lay-event="zxjh" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>执行计划
                    </a>

                    <a id="kfcg" lay-event="kfcg" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>开发成功
                    </a>
                    {{# }if(d.status =='已指派') { }}
                    <a id="zdjh" lay-event="zdjh" class="layui-btn layui-btn-normal layui-btn-xs">
                        <i class="layui-icon layui-icon-edit"></i>制定计划
                    </a>

                    <a id="zxjh" lay-event="zxjh" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>执行计划
                    </a>

                    <a id="kfcg" lay-event="kfcg" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>开发成功
                    </a>
                    {{# }if(d.status =='开发成功') { }}
                    <a id="ck" lay-event="ck" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>查看
                    </a>
                    {{# }if(d.status =='开发失败') { }}
                    <a id="ck" lay-event="ck" class="layui-btn layui-btn-danger layui-btn-xs">
                        <i class="layui-icon layui-icon-delete"></i>查看
                    </a>
                    {{#  } }}


                </script>

            </div>

        </div>
    </div>
</div>

<script>

    layui.use(['form','table','layer','laydate','layedit'], function(){
        var $ = layui.$
            ,table = layui.table
            ,form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,layedit = layui.layedit;

        //表格
        table.render({
            elem: '#test'
            ,url: '<c:url value="/PlaneSelectAll.do"/>' //模拟接口
            ,cols: [[
                {field: 'sale_opportunityId', title: 'sale_opportunityId',style:'display:none;'},
                {field: 'customerId', title: 'customerId',style:'display:none;'},
                {field: 'linkmanId', title: 'linkmanId',style:'display:none;'},
                {field: 'manager_id', title: 'manager_id',style:'display:none;'},

                {field: 'creater', title: 'creater',style:'display:none;'},
                {field: 'allot_date', title: 'allot_date',style:'display:none;'},
                {field: 'description', title: 'description',style:'display:none;'},
                {field: 'success', title: 'success',style:'display:none;'},
                {field: 'source', title: 'source',style:'display:none;'}


                // ,{field: 'rownu', title: 'id' ,width:60}
                ,{field: 'name', title: '客户名称',width:90}
                ,{field: 'general', title: '概要' ,templet: '#imgTpl',width:252}
                ,{field: 'customerName', title: '联系人',width:120}
                ,{field: 'mobile_phone', title: '联系电话',width:136}
                ,{field: 'create_date', title: '创建时间',width:200}
                ,{field: 'status', title: '状态',sort: true,width:120}
                ,{title: '操作', align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser',width:498.117}
            ]]
            ,page: true
            // 表格ID，必须设置，重载部分需要用到
            , id: 'tableOne'
            ,limits: [5,10, 15, 20, 25]
            ,limit: 10
            ,text: '对不起，加载出现异常！'
            ,response: {
                statusName: 'code',// 对应 code
                msgName: 'mag', // 对应 msg
                countName: 'count', // 对应 count
                dataName: 'data'  // 对应 data
            }
            ,text:{none: '无数据'}
            ,done: function(res, curr, count) {

                $("[data-field='status']").children().each(function () {

                    if ($(this).text() == '已指派') {
                        $(this).text("开发中")
                    }
                    else if ($(this).text() == '开发失败') {
                        $(this).text("已归档")
                    } else if ($(this).text() == '开发成功') {
                        $(this).text("已归档")
                    }
                });
            }

        });

        $('table.layui-table thead tr th:eq(0)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(1)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(2)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(3)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(4)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(5)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(6)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(7)').addClass('layui-hide');
        $('table.layui-table thead tr th:eq(8)').addClass('layui-hide');
        //------------------------------------------------------------------------------------------------------------

        // 执行搜索，表格重载
        $('#search').click(function () {
            // 搜索条件
            var general = $('#general').val();
            var customerName = $('#customerName').val();
            var name = $('#name').val();
            table.reload('tableOne',{
                elem: '#test'
                ,method:'post'
                ,where: {
                    'name': name,
                    'general': general,
                    'customerName': customerName,
                }
                ,url: '<c:url value="/QueryPlaneSelectAll.do"/>' //模拟接口
                ,page: true
                ,limits: [5,10, 15, 20, 25]
                ,limit: 10
                ,text: '对不起，加载出现异常！'
                ,response: {
                    statusName: 'code',// 对应 code
                    msgName: 'mag', // 对应 msg
                    countName: 'count', // 对应 count
                    dataName: 'data'  // 对应 data
                }
                ,cols: [[
                    {field: 'sale_opportunityId', title: 'sale_opportunityId',style:'display:none;'},
                    {field: 'customerId', title: 'customerId',style:'display:none;'},
                    {field: 'linkmanId', title: 'linkmanId',style:'display:none;'},
                    {field: 'manager_id', title: 'manager_id',style:'display:none;'},

                    {field: 'creater', title: 'creater',style:'display:none;'},
                    {field: 'allot_date', title: 'allot_date',style:'display:none;'},
                    {field: 'description', title: 'description',style:'display:none;'},
                    {field: 'success', title: 'success',style:'display:none;'},
                    {field: 'source', title: 'source',style:'display:none;'}


                    // ,{field: 'rownu', title: 'id' ,width:60}
                    ,{field: 'name', title: '客户名称',width:90}
                    ,{field: 'general', title: '概要' ,templet: '#imgTpl',width:252}
                    ,{field: 'customerName', title: '联系人',width:120}
                    ,{field: 'mobile_phone', title: '联系电话',width:136}
                    ,{field: 'create_date', title: '创建时间',width:200}
                    ,{field: 'status', title: '状态',sort: true,width:120}
                    ,{title: '操作', align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser',width:498.117}
                ]]
                ,text:{none: '无数据'}
                ,done: function(res, curr, count) {

                    $("[data-field='status']").children().each(function () {
                        if ($(this).text() == '已指派') {
                            $(this).text("开发中")
                        }
                        else if ($(this).text() == '开发失败') {
                            $(this).text("已归档")
                        } else if ($(this).text() == '开发成功') {
                            $(this).text("已归档")
                        }
                    });
                }
            });
            $('table.layui-table thead tr th:eq(0)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(1)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(2)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(3)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(4)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(5)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(6)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(7)').addClass('layui-hide');
            $('table.layui-table thead tr th:eq(8)').addClass('layui-hide');
        });

        <%--//--------------------------------------------------------------------------------------------------------------%>

        //监听工具条
        table.on('tool(test)', function(obj){
            <%--if (${sessionScope.user.roleId!=1} && ${sessionScope.user.roleId!=2}){--%>
            <%--    layer.alert("对不起，您没有操作权限 ！");--%>
            <%--    return;--%>
            <%--}--%>
            var data = JSON.stringify(obj.data);
            $.ajax({
                url: '<c:url value="/planeGetSj.do"/>',
                type:'post',
                dataType:'text',
                data:{
                    jsonString : data
                }
            })
            //制定计划
            if(obj.event === 'zdjh'){
                layer.open({
                    type: 2,
                    offset: 't',
                    title: '制定计划',
                    area: ['1718px', '882px'],
                    shadeClose: false, //点击遮罩关闭
                    content: 'dev_plan.jsp',
                });
            }
            //执行计划
            if(obj.event === 'zxjh'){
                layer.open({
                    type: 2,
                    offset: 't',
                    title: '执行计划',
                    area: ['1718px', '882px'],
                    shadeClose: false, //点击遮罩关闭
                    content: 'dev_execute.jsp',
                });
            }
            //
            if(obj.event === 'kfcg'){
                $.ajax({
                    url: '<c:url value="/updexploitSuccess1.do"/>',
                    type:'get',
                    dataType:'text',
                    success:function(msg){
                        if (msg=="success"){
                            layer.confirm('开发成功', {icon: 1, title:'提示'}, function(index){
                                //do something

                                layer.close(index);
                                location.href="plane.jsp";
                            });
                        }else{
                            layer.confirm('操作失败', {icon: 2, title:'提示'}, function(index){
                                //do something

                                layer.close(index);
                            });
                        }
                    }
                })
            }
            if(obj.event === 'ck'){
                layer.open({
                    type: 2,
                    offset: 't',
                    title: '查看',
                    area: ['1718px', '882px'],
                    shadeClose: false, //点击遮罩关闭
                    content: 'dev_detail.jsp',
                });
            }
        });

    });


</script>

</body>
</html>
